package Week9;

import java.util.Scanner;

public class Main1 {

	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		IntegerStack arrayListIntegerStack = new ArrayListIntegerStack();
		int m = sc.nextInt();
		
		for(int i = 0;i<m;i++){
			System.out.println(arrayListIntegerStack.push(sc.nextInt()));
			
		}
		System.out.println(arrayListIntegerStack.peek()+","+arrayListIntegerStack.empty()+","+arrayListIntegerStack.size());
		System.out.println(arrayListIntegerStack.toString());
		
		int x =sc.nextInt();
		for(int i=0;i<x;i++){
			System.out.println(arrayListIntegerStack.pop());
		}
		System.out.println(arrayListIntegerStack.peek()+","+arrayListIntegerStack.empty()+","+arrayListIntegerStack.size());
		System.out.println(arrayListIntegerStack.toString());
	}

	

}

